home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / CIncludes / Controls.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-17  |  11.6 KB  |  376 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Controls.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __CONTROLS__
  18. #define __CONTROLS__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __QUICKDRAW__
  27. #include <Quickdraw.h>
  28. #endif
  29. /*    #include <MixedMode.h>                                        */
  30. /*    #include <QuickdrawText.h>                                    */
  31.  
  32. #ifndef __MENUS__
  33. #include <Menus.h>
  34. #endif
  35. /*    #include <Memory.h>                                            */
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if GENERATINGPOWERPC
  42. #pragma options align=mac68k
  43. #endif
  44.  
  45. #ifdef __CFM68K__
  46. #pragma lib_export on
  47. #endif
  48.  
  49.  
  50. enum {
  51.     pushButProc                    = 0,
  52.     checkBoxProc                = 1,
  53.     radioButProc                = 2,
  54.     useWFont                    = 8,
  55.     scrollBarProc                = 16,
  56.     popupMenuProc                = 1008                            /* 63 * 16 */
  57. };
  58.  
  59. enum {
  60.     inLabel                        = 1,
  61.     inMenu                        = 2,
  62.     inTriangle                    = 4
  63. };
  64.  
  65. typedef UInt8 ControlPartCode;
  66.  
  67.  
  68. enum {
  69.     kNoHiliteControlPart        = 0,
  70.     kInButtonControlPart        = 10,
  71.     kInCheckBoxControlPart        = 11,
  72.     kInUpButtonControlPart        = 20,
  73.     kInDownButtonControlPart    = 21,
  74.     kInPageUpControlPart        = 22,
  75.     kInPageDownControlPart        = 23,
  76.     kInIndicatorControlPart        = 129,
  77.     kReservedControlPart        = 254,
  78.     kControlInactiveControlPart    = 255
  79. };
  80.  
  81. enum {
  82.     inButton                    = 10,
  83.     inCheckBox                    = 11,
  84.     inUpButton                    = 20,
  85.     inDownButton                = 21,
  86.     inPageUp                    = 22,
  87.     inPageDown                    = 23,
  88.     inThumb                        = 129
  89. };
  90.  
  91. enum {
  92.     popupFixedWidth                = 1 << 0,
  93.     popupVariableWidth            = 1 << 1,
  94.     popupUseAddResMenu            = 1 << 2,
  95.     popupUseWFont                = 1 << 3
  96. };
  97.  
  98. enum {
  99.     popupTitleBold                = 1 << 8,
  100.     popupTitleItalic            = 1 << 9,
  101.     popupTitleUnderline            = 1 << 10,
  102.     popupTitleOutline            = 1 << 11,
  103.     popupTitleShadow            = 1 << 12,
  104.     popupTitleCondense            = 1 << 13,
  105.     popupTitleExtend            = 1 << 14,
  106.     popupTitleNoStyle            = 1 << 15
  107. };
  108.  
  109. enum {
  110.     popupTitleLeftJust            = 0x00000000,
  111.     popupTitleCenterJust        = 0x00000001,
  112.     popupTitleRightJust            = 0x000000FF
  113. };
  114.  
  115. /*
  116. axis constraints for DragGrayRgn call*/
  117. enum {
  118.     noConstraint                = kNoConstraint,
  119.     hAxisOnly                    = 1,
  120.     vAxisOnly                    = 2
  121. };
  122.  
  123. typedef SInt16 ControlDefProcMessage;
  124.  
  125.  
  126. enum {
  127.     drawCntl                    = 0,
  128.     testCntl                    = 1,
  129.     calcCRgns                    = 2,
  130.     initCntl                    = 3,
  131.     dispCntl                    = 4,
  132.     posCntl                        = 5,
  133.     thumbCntl                    = 6,
  134.     dragCntl                    = 7,
  135.     autoTrack                    = 8,
  136.     calcCntlRgn                    = 10,
  137.     calcThumbRgn                = 11,
  138.     drawThumbOutline            = 12
  139. };
  140.  
  141. enum {
  142.     cFrameColor                    = 0,
  143.     cBodyColor                    = 1,
  144.     cTextColor                    = 2,
  145.     cThumbColor                    = 3
  146. };
  147.  
  148. /*
  149.     Set STRICT_CONTROLS to 1 to make sure your code 
  150.     doesn't access the control records directly
  151. */
  152. #ifndef STRICT_CONTROLS
  153. #define STRICT_CONTROLS 0
  154. #endif
  155. #if STRICT_CONTROLS
  156. typedef void *ControlRef;
  157.  
  158. typedef ControlRef ControlHandle;
  159.  
  160. #else
  161. typedef struct ControlRecord ControlRecord, *ControlPtr, **ControlHandle;
  162.  
  163. typedef ControlHandle ControlRef;
  164.  
  165. #endif
  166. typedef pascal long (*ControlDefProcPtr)(short varCode, ControlRef theControl, short message, long param);
  167. typedef pascal void (*ControlActionProcPtr)(ControlRef theControl, short partCode);
  168.  
  169. #if GENERATINGCFM
  170. typedef UniversalProcPtr ControlDefUPP;
  171. typedef UniversalProcPtr ControlActionUPP;
  172. #else
  173. typedef ControlDefProcPtr ControlDefUPP;
  174. typedef ControlActionProcPtr ControlActionUPP;
  175. #endif
  176.  
  177. #if !STRICT_CONTROLS
  178. struct ControlRecord {
  179.     ControlRef                        nextControl;
  180.     WindowRef                        contrlOwner;
  181.     Rect                            contrlRect;
  182.     UInt8                            contrlVis;
  183.     UInt8                            contrlHilite;
  184.     short                            contrlValue;
  185.     short                            contrlMin;
  186.     short                            contrlMax;
  187.     Handle                            contrlDefProc;
  188.     Handle                            contrlData;
  189.     ControlActionUPP                contrlAction;
  190.     long                            contrlRfCon;
  191.     Str255                            contrlTitle;
  192. };
  193. #endif
  194. struct PopupPrivateData {
  195.     MenuHandle                        mHandle;                    /*popup menu handle*/
  196.     short                            mID;                        /*popup menu ID*/
  197. };
  198. typedef struct PopupPrivateData PopupPrivateData;
  199.  
  200. typedef PopupPrivateData *PopupPrivateDataPtr, **PopupPrivateDataHandle;
  201.  
  202. struct CtlCTab {
  203.     long                            ccSeed;                        /*reserved*/
  204.     short                            ccRider;                    /*see what you have done - reserved*/
  205.     short                            ctSize;                        /*usually 3 for controls*/
  206.     ColorSpec                        ctTable[4];
  207. };
  208. typedef struct CtlCTab CtlCTab;
  209.  
  210. typedef CtlCTab *CCTabPtr, **CCTabHandle;
  211.  
  212. #if !STRICT_CONTROLS
  213. struct AuxCtlRec {
  214.     Handle                            acNext;
  215.     ControlRef                        acOwner;
  216.     CCTabHandle                        acCTable;
  217.     short                            acFlags;
  218.     long                            acReserved;
  219.     long                            acRefCon;
  220. };
  221. typedef struct AuxCtlRec AuxCtlRec;
  222.  
  223. typedef AuxCtlRec *AuxCtlPtr, **AuxCtlHandle;
  224.  
  225. #endif
  226. enum {
  227.     uppControlDefProcInfo = kPascalStackBased
  228.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  229.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  230.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ControlRef)))
  231.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  232.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long))),
  233.     uppControlActionProcInfo = kPascalStackBased
  234.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ControlRef)))
  235.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  236. };
  237.  
  238. #if GENERATINGCFM
  239. #define NewControlDefProc(userRoutine)        \
  240.         (ControlDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlDefProcInfo, GetCurrentArchitecture())
  241. #define NewControlActionProc(userRoutine)        \
  242.         (ControlActionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlActionProcInfo, GetCurrentArchitecture())
  243. #else
  244. #define NewControlDefProc(userRoutine)        \
  245.         ((ControlDefUPP) (userRoutine))
  246. #define NewControlActionProc(userRoutine)        \
  247.         ((ControlActionUPP) (userRoutine))
  248. #endif
  249.  
  250. #if GENERATINGCFM
  251. #define CallControlDefProc(userRoutine, varCode, theControl, message, param)        \
  252.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppControlDefProcInfo, (varCode), (theControl), (message), (param))
  253. #define CallControlActionProc(userRoutine, theControl, partCode)        \
  254.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppControlActionProcInfo, (theControl), (partCode))
  255. #else
  256. #define CallControlDefProc(userRoutine, varCode, theControl, message, param)        \
  257.         (*(userRoutine))((varCode), (theControl), (message), (param))
  258. #define CallControlActionProc(userRoutine, theControl, partCode)        \
  259.         (*(userRoutine))((theControl), (partCode))
  260. #endif
  261.  
  262. extern pascal ControlRef NewControl(WindowRef theWindow, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short value, short min, short max, short procID, long refCon)
  263.  ONEWORDINLINE(0xA954);
  264. extern pascal void SetControlTitle(ControlRef theControl, ConstStr255Param title)
  265.  ONEWORDINLINE(0xA95F);
  266. extern pascal void GetControlTitle(ControlRef theControl, Str255 title)
  267.  ONEWORDINLINE(0xA95E);
  268. extern pascal ControlRef GetNewControl(short controlID, WindowRef owner)
  269.  ONEWORDINLINE(0xA9BE);
  270. extern pascal void DisposeControl(ControlRef theControl)
  271.  ONEWORDINLINE(0xA955);
  272. extern pascal void KillControls(WindowRef theWindow)
  273.  ONEWORDINLINE(0xA956);
  274. extern pascal void HideControl(ControlRef theControl)
  275.  ONEWORDINLINE(0xA958);
  276. extern pascal void ShowControl(ControlRef theControl)
  277.  ONEWORDINLINE(0xA957);
  278. extern pascal void DrawControls(WindowRef theWindow)
  279.  ONEWORDINLINE(0xA969);
  280. extern pascal void Draw1Control(ControlRef theControl)
  281.  ONEWORDINLINE(0xA96D);
  282. extern pascal void HiliteControl(ControlRef theControl, short hiliteState)
  283.  ONEWORDINLINE(0xA95D);
  284. extern pascal void UpdateControls(WindowRef theWindow, RgnHandle updateRgn)
  285.  ONEWORDINLINE(0xA953);
  286. extern pascal void MoveControl(ControlRef theControl, short h, short v)
  287.  ONEWORDINLINE(0xA959);
  288. extern pascal void SizeControl(ControlRef theControl, short w, short h)
  289.  ONEWORDINLINE(0xA95C);
  290. extern pascal void SetControlValue(ControlRef theControl, short theValue)
  291.  ONEWORDINLINE(0xA963);
  292. extern pascal short GetControlValue(ControlRef theControl)
  293.  ONEWORDINLINE(0xA960);
  294. extern pascal void SetControlMinimum(ControlRef theControl, short minValue)
  295.  ONEWORDINLINE(0xA964);
  296. extern pascal short GetControlMinimum(ControlRef theControl)
  297.  ONEWORDINLINE(0xA961);
  298. extern pascal void SetControlMaximum(ControlRef theControl, short maxValue)
  299.  ONEWORDINLINE(0xA965);
  300. extern pascal short GetControlMaximum(ControlRef theControl)
  301.  ONEWORDINLINE(0xA962);
  302. #if !STRICT_CONTROLS
  303. extern pascal Boolean GetAuxiliaryControlRecord(ControlRef theControl, AuxCtlHandle *acHndl)
  304.  ONEWORDINLINE(0xAA44);
  305. #endif
  306. extern pascal void SetControlReference(ControlRef theControl, long data)
  307.  ONEWORDINLINE(0xA95B);
  308. extern pascal long GetControlReference(ControlRef theControl)
  309.  ONEWORDINLINE(0xA95A);
  310. extern pascal void SetControlAction(ControlRef theControl, ControlActionUPP actionProc)
  311.  ONEWORDINLINE(0xA96B);
  312. extern pascal ControlActionUPP GetControlAction(ControlRef theControl)
  313.  ONEWORDINLINE(0xA96A);
  314. extern pascal void DragControl(ControlRef theControl, Point startPt, const Rect *limitRect, const Rect *slopRect, short axis)
  315.  ONEWORDINLINE(0xA967);
  316. extern pascal short TestControl(ControlRef theControl, Point thePt)
  317.  ONEWORDINLINE(0xA966);
  318. extern pascal short FindControl(Point thePoint, WindowRef theWindow, ControlRef *theControl)
  319.  ONEWORDINLINE(0xA96C);
  320. extern pascal void SetControlColor(ControlRef theControl, CCTabHandle newColorTable)
  321.  ONEWORDINLINE(0xAA43);
  322. extern pascal short GetControlVariant(ControlRef theControl)
  323.  ONEWORDINLINE(0xA809);
  324. /*
  325.     When using the TrackControl() call when tracking an indicator, the
  326.     actionProc parameter (type ControlActionUPP) should be replaced by
  327.     a parameter of type DragGrayRgnUPP (defined in Quickdraw.<header>).
  328. */
  329. extern pascal short TrackControl(ControlRef theControl, Point thePoint, ControlActionUPP actionProc)
  330.  ONEWORDINLINE(0xA968);
  331. #if CGLUESUPPORTED
  332. extern void dragcontrol(ControlRef theControl, Point *startPt, const Rect *limitRect, const Rect *slopRect, short axis);
  333. extern ControlRef newcontrol(WindowRef theWindow, const Rect *boundsRect, const char *title, Boolean visible, short value, short min, short max, short procID, long refCon);
  334. extern short findcontrol(Point *thePoint, WindowRef theWindow, ControlRef *theControl);
  335. extern void getcontroltitle(ControlRef theControl, char *title);
  336. extern void setcontroltitle(ControlRef theControl, const char *title);
  337. extern short trackcontrol(ControlRef theControl, Point *thePoint, ControlActionUPP actionProc);
  338. extern short testcontrol(ControlRef theControl, Point *thePt);
  339. #endif
  340. #if OLDROUTINENAMES
  341. #define SetCTitle(theControl, title) SetControlTitle(theControl, title)
  342. #define GetCTitle(theControl, title) GetControlTitle(theControl, title)
  343. #define UpdtControl(theWindow, updateRgn) UpdateControls(theWindow, updateRgn)
  344. #define SetCtlValue(theControl, theValue) SetControlValue(theControl, theValue)
  345. #define GetCtlValue(theControl) GetControlValue(theControl)
  346. #define SetCtlMin(theControl, minValue) SetControlMinimum(theControl, minValue)
  347. #define GetCtlMin(theControl) GetControlMinimum(theControl)
  348. #define SetCtlMax(theControl, maxValue) SetControlMaximum(theControl, maxValue)
  349. #define GetCtlMax(theControl) GetControlMaximum(theControl)
  350. #define GetAuxCtl(theControl, acHndl) GetAuxiliaryControlRecord(theControl, acHndl)
  351. #define SetCRefCon(theControl, data) SetControlReference(theControl, data)
  352. #define GetCRefCon(theControl) GetControlReference(theControl)
  353. #define SetCtlAction(theControl, actionProc) SetControlAction(theControl, actionProc)
  354. #define GetCtlAction(theControl) GetControlAction(theControl)
  355. #define SetCtlColor(theControl, newColorTable) SetControlColor(theControl, newColorTable)
  356. #define GetCVariant(theControl) GetControlVariant(theControl)
  357. #if CGLUESUPPORTED
  358. #define getctitle(theControl, title) getcontroltitle(theControl, title)
  359. #define setctitle(theControl, title) setcontroltitle(theControl, title)
  360. #endif
  361. #endif
  362.  
  363. #ifdef __CFM68K__
  364. #pragma lib_export off
  365. #endif
  366.  
  367. #if GENERATINGPOWERPC
  368. #pragma options align=reset
  369. #endif
  370.  
  371. #ifdef __cplusplus
  372. }
  373. #endif
  374.  
  375. #endif /* __CONTROLS__ */
  376.